package com.room.mapper;

import com.room.pojo.Role;
import com.room.pojo.Student;
import com.room.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @创建人 lin
 * @创建时间 2019/9/28
 * @描述
 */
public interface
UserMapper {



    @Delete("delete from user where username = #{username}")
    int deleteUserByUserName(String username);


    //   通过用户名获取用户id
    @Select("select id from user where username = #{username}")
    Long getUserIdByUserName(String username);

    int deleteUserByUser(@Param("ids")String[] ids);

    @Insert({ "insert into user ( name, username, password ) values(#{name}, #{username}, #{password})"})
    public int insetUser(User user);

    User loadUserByUsername(String username);

    List<Role> getRolesByUserId(Long id);

    int userReg(@Param("username") String username, @Param("password") String password);

    List<User> getUsersByKeywords(@Param("keywords") String keywords);

    int updateUser(User user);

    int deleteRoleByUserId(Long userId);

    int addRolesForUser(@Param("userId") Long userId, @Param("rids") Long[] rids);

    User getUserById(Long userId);

    int deleteUser(Long userId);

    List<User> getAllUser(@Param("currentId") Long currentId);


    List<User> getUserByPage(@Param("start")Integer start, @Param("size")Integer size);


    @Select("select * from user where username = #{username}")
    User getUserByUsername(@Param("username") String username);

    @Update("update user set password = #{password} where username = #{username}")
    int updatePwdByUsername(@Param("username") String username,@Param("password") String password);

   List<Role> getRolesByUserId(@Param("id")long id);

   long getUserMaxId();


}
